import { request } from "@/utils/http";
import type {HospitalSetItem, ReqAddHospitalParams, ReqHospitalSetListParams,ReqHospitalSetListResponse, ReqUpdateHospitalParams} from "./model/hospitalSetTypes";
import type { Key} from "react";

//获取医院列表 (请求获取医院设置列表)
export const reqGetHospitalSetList = ({page,limit,hosname,hoscode}:ReqHospitalSetListParams) =>{
  return request.get<any,ReqHospitalSetListResponse>(`/admin/hosp/hospitalSet/${page}/${limit}`,{
    // query 参数
    params:{
      hosname:hosname,
      hoscode:hoscode
    }
  })
}

//添加医院
export const reqAddHospital = (hospital:ReqAddHospitalParams)=>{
    // 添加/更新/删除请求接口返回的响应数据的data属性为null
    return request.post<any,null>(`/admin/hosp/hospitalSet/save`,hospital)
}

// 获取某个医院数据
export const reqGetHospital = (id:number)=>{
  return request.get<any,HospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`)
}

//修改医院信息
export const reqUpdateHospital =(hospital:ReqUpdateHospitalParams)=>{
  return request.put<any,null>("/admin/hosp/hospitalSet/update",hospital)
}

//删除医院
export const reqRemoveHospital =(id:number)=>{
  return request.delete(`/admin/hosp/hospitalSet/remove/${id}`);
};

//批量删除医院
export const reqBatchRemoveHospitalList =  (idList:Key[])=>{
  return request.delete("/admin/hosp/hospitalSet/batchRemove",{
    // 如果是post/put可以直接写参数，但是get/delete要携带body参数必须这样写
    data:idList
  });
};